package app.tool;

import java.io.File;

import org.rygh.core.util.UIo;
import org.rygh.core.util.UTime;

import app.App;

public class tex extends App {

	public static void main(String[] args) {
		table1();
		bye();
	}

	static void table1() {
		String[][][] values = {
				/**/{
						/**/{ "Music", },
						/**/{ "MusicBrainz", "Last.fm", "Discogs", "Deezer",
								"Echonest", "Musixmatch" },
						/**/{ "ArtistByName", "person", "ArtistById",
								"identifier", "AlbumByName", "album",
								"AlbumById", "identifier",
								"AlbumsByArtistName", "person",
								"AlbumsByArtistId", "identifier",
								"MasterAlbumByName", "album",

								"SongByName", "song", "SongById", "identifier",
								"SongsByArtistName", "person",
								"SongsByArtistId", "identifier",
								"SongsByAlbumId", "identifier",
								"TopSongsByArtistId", "identifier", }, },
				/**/{
				/**/{ "Movies", },
				/**/{ "MyMovieApi", "", "IMDBApi" },
				/**/{ "MovieByName", "movie", "MovieByIMDB", "identifier" }, },
				/**/{
						/**/{ "Books", },
						/**/{ "ISBNdb", "", "LibraryThing", },
						/**/{ "AuthorByName", "person", "AuthorById",
								"identifier", "BookByName", "book", "BookById",
								"identifier", "BookByISBN", "identifier",
								"PublisherByName", "publisher",
								"PublisherById", "identifier" }, },
				/**/{
						/**/{ "Geography", },
						/**/{ "", "Geonames", "" },
						/**/{ "CountryByName", "country", "CountryById",
								"identifier", "NeighborsByCountryId",
								"identifier", "CityByName", "city" },
				/**/}, };

		StringBuilder sb = new StringBuilder();
		File dir = new File(
				"/home/nanmus/Data/Dropbox/Shared/ClementThesis/Documents/Paper/exp/");

		sb.append(String.format("%% generated on %s\n", UTime.toHumanString()));
		sb.append("\\begin{tabular}{|l@{}|@{}l@{}|@{}l@{}|}\n");
		sb.append("\\hline\n");
		sb.append("\\multirow{2}{*}{\\bf Web Service} & "
				+ "\\multirow{2}{*}{\\quad \\bf Functions} & "
				+ "\\quad \\bf Input \\\\  & & \\quad \\bf Type  \\\\ \n");
		sb.append("\\hline\n");

		int i;

		for (String[][] ws : values) {
			sb.append(String.format("\\rotatebox[origin=c]{90}{%s}", ws[0][0]));
			sb.append("$\\left\\{%\n");
			sb.append("\\begin{array}{l}");

			for (String s : ws[1])
				sb.append(String.format(" \\text{%s} \\\\", s));

			sb.append("\\end{array}\\right.$ & \n");
			sb.append("\\begin{tabular}{l}");

			for (i = 0; i < ws[2].length; i += 2)
				sb.append(String.format(" %s \\\\", ws[2][i]));

			sb.append("\\end{tabular} & \n");
			sb.append("\\begin{tabular}{l}");

			for (i = 1; i < ws[2].length; i += 2)
				sb.append(String.format(" %s \\\\", ws[2][i]));

			sb.append("\\end{tabular} \\\\ \n");
			sb.append("\\hline\n");
		}

		sb.append("\\end{tabular}");

		UIo.saveFile(new File(dir, "exp_table_1.tex"), sb.toString());
	}

	static void table2() {
		String[][][] values = {
				/**/{
						/**/{ "MusicBrainz", },
						/**/{ "name", "gender", "life-span/begin",
								"life-span/end", "begin-area/name",
								"end-area/name", "area/name" }, },
				/**/{
						/**/{ "YAGO2", },
						/**/{ "hasPreferredName", "hasGender.label",
								"wasBornOnDate", "diedOnDate",
								"wasBornIn.label", "diedIn.label",
								"isCitizenOf.label" }, }, };

		StringBuilder sb = new StringBuilder();
		File dir = new File(
				"/home/nanmus/Data/Dropbox/Shared/ClementThesis/Documents/Paper/exp/");

		sb.append(String.format("%% generated on %s\n", UTime.toHumanString()));
		sb.append("\\begin{tabular}{|c|c|}\n");
		sb.append("\\hline\n");
		sb.append("\\bf Labeled Path & \\bf Predicate Path \\\\\n");
		sb.append("\\hline\n");

		String[][] ws = values[0];

		sb.append(String.format("\\rotatebox[origin=c]{90}{%s}", ws[0][0]));
		sb.append("$\\left\\{%\n");
		sb.append("\\begin{array}{l}\n");

		for (String s : ws[1])
			sb.append(String.format(" \\text{%s} \\\\\n", s));

		sb.append("\\end{array}\\right.$ & \n");

		ws = values[1];

		sb.append("$\\left.%\n");
		sb.append("\\begin{array}{l}\n");

		for (String s : ws[1])
			sb.append(String.format(" \\text{%s} \\\\\n", s));

		sb.append("\\end{array}\\right\\}$");
		sb.append(String.format("\\rotatebox[origin=c]{90}{%s} \\\\\n",
				ws[0][0]));
		sb.append("\\hline \n");

		sb.append("\\end{tabular}");

		UIo.saveFile(new File(dir, "exp_table_path_example.tex"), sb.toString());
	}
}
